//引入样式
require('../../assets/css/reset.css');
require('../../assets/fonts/iconfont.css');
require('./me.less');
require('../../assets/css/tabbar.less')
//引入模块
let axios = require('../../utils/axios.js')
let dom = require('../../utils/dom.js')

document.addEventListener("DOMContentLoaded", function () {
    //渲染底部导航
    dom.tabbar('me');


    //发请求获取用户个人信息
    axios.get('/api/user/info').then(res => {
        //获取后台数据的用户名
        let nickName = res.data.data.nickName
        //在页面渲染用户名
        dom.get('.nickName').textContent = nickName

        //获取到头像信息
        let imgUrl = res.data.data.imgUrl
        //在页面渲染头像
        dom.get('.imgUrl').style.background = `url("${axios.defaults.baseURL}${imgUrl}") no-repeat center/cover `

        //获取后台的签名
        let sign = res.data.data.sign
        //在页面渲染签名
        dom.get('.sign').textContent = sign

        //获取总运动时间
        let duration = res.data.data.duration
        //在页面渲染消耗总运动时间
        dom.get('.duration').textContent = duration

        //获取消耗的卡路里
        let calorie = res.data.data.calorie
        //在页面渲染消耗的卡路里
        dom.get('.calorie').textContent = calorie
    });
    dom.get('#exit').addEventListener('click', function () {
        localStorage.removeItem('token')
    }
    )

})


